// Package sysin
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.15.11
package sysin

import (
	"context"
	"hotgo/internal/model/entity"
	"hotgo/internal/model/input/form"

	"github.com/gogf/gf/v2/encoding/gjson"
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/os/gtime"
)

// StoreMemberUpdateFields 修改门店账号管理字段过滤
type StoreMemberUpdateFields struct {
	StoreId  int64 `json:"storeId"  dc:"门店 id"`
	MemberId int64 `json:"memberId" dc:"账号 id"`
	IsAdmin  int   `json:"isAdmin"  dc:"是否是管理员"`
}

// StoreMemberInsertFields 新增门店账号管理字段过滤
type StoreMemberInsertFields struct {
	StoreId  int64 `json:"storeId"  dc:"门店 id"`
	MemberId int64 `json:"memberId" dc:"账号 id"`
	IsAdmin  int   `json:"isAdmin"  dc:"是否是管理员"`
}

// StoreMemberEditInp 修改/新增门店账号管理
type StoreMemberEditInp struct {
	entity.StoreMember
}

func (in *StoreMemberEditInp) Filter(ctx context.Context) (err error) {
	// 验证门店 id
	if err := g.Validator().Rules("required").Data(in.StoreId).Messages("门店 id不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	// 验证账号 id
	if err := g.Validator().Rules("required").Data(in.MemberId).Messages("账号 id不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	return
}

type StoreMemberEditModel struct{}

// StoreMemberDeleteInp 删除门店账号管理
type StoreMemberDeleteInp struct {
	Id interface{} `json:"id" v:"required#id不能为空" dc:"id"`
}

func (in *StoreMemberDeleteInp) Filter(ctx context.Context) (err error) {
	return
}

type StoreMemberDeleteModel struct{}

// StoreMemberViewInp 获取指定门店账号管理信息
type StoreMemberViewInp struct {
	Id int64 `json:"id" v:"required#id不能为空" dc:"id"`
}

func (in *StoreMemberViewInp) Filter(ctx context.Context) (err error) {
	return
}

type StoreMemberViewModel struct {
	Id                  int64       `json:"id"        orm:"id"         description:""`
	StoreId             int64       `json:"storeId"   orm:"store_id"   description:"门店 id"`
	MemberId            int64       `json:"memberId"  orm:"member_id"  description:"账号 id"`
	IsAdmin             int         `json:"isAdmin"   orm:"is_admin"   description:"是否是管理员"`
	CreatedAt           *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"`
	AdminMemberRealName string      `json:"adminMemberRealName" dc:"真实姓名"`
	AdminMemberUsername string      `json:"adminMemberUsername" dc:"帐号"`
	AdminMemberMobile   string      `json:"adminMemberMobile"   dc:"手机号码"`
	AdminMemberAvatar   string      `json:"adminMemberAvatar"   dc:"头像"`
	AdminMemberNickname string      `json:"adminMemberNickname" dc:"昵称"`
	AdminMemberSex      int         `json:"adminMemberSex"      dc:"性别"`
	StoreName           string      `json:"storeName"           dc:"门店名称"`
	StorePhone          string      `json:"storePhone"          dc:"门店电话"`
}

// StoreMemberListInp 获取门店账号管理列表
type StoreMemberListInp struct {
	form.PageReq
	*form.Sorters
	Id                  int64         `json:"id"                  dc:"id"`
	IsAdmin             int           `json:"isAdmin"             dc:"是否是管理员"`
	CreatedAt           []*gtime.Time `json:"createdAt"           dc:"创建时间"`
	MemberId            int64         `json:"memberId"            dc:"账号 id"`
	AdminMemberRealName string        `json:"adminMemberRealName" dc:"真实姓名"`
	AdminMemberUsername string        `json:"adminMemberUsername" dc:"帐号"`
	AdminMemberMobile   string        `json:"adminMemberMobile"   dc:"手机号码"`
	StoreID             int64         `json:"storeId"             dc:"门店 id"`
	StoreName           string        `json:"storeName"           dc:"门店名称"`
	StorePhone          string        `json:"storePhone"          dc:"门店电话"`
}

func (in *StoreMemberListInp) Filter(ctx context.Context) (err error) {
	return
}

type StoreMemberListModel struct {
	Id                  int64           `json:"id"                  dc:"id"`
	StoreId             int64           `json:"storeId"             dc:"门店 id"`
	MemberId            int64           `json:"memberId"            dc:"账号 id"`
	IsAdmin             int             `json:"isAdmin"             dc:"是否是管理员"`
	CreatedAt           *gtime.Time     `json:"createdAt"           dc:"创建时间"`
	AdminMemberRealName string          `json:"adminMemberRealName" dc:"真实姓名"`
	AdminMemberUsername string          `json:"adminMemberUsername" dc:"帐号"`
	AdminMemberAvatar   string          `json:"adminMemberAvatar"   dc:"头像"`
	AdminMemberMobile   string          `json:"adminMemberMobile"   dc:"手机号码"`
	AdminMemberNickname string          `json:"adminMemberNickname" dc:"昵称"`
	AdminMemberSex      int             `json:"adminMemberSex"      dc:"性别"`
	StoreName           string          `json:"storeName"           dc:"门店名称"`
	StorePhone          string          `json:"storePhone"          dc:"门店电话"`
	StorePublicityImgs  *gjson.Json     `json:"storePublicityImgs"  dc:"门店图片"`
	StoreData           *StoreDataModel `json:"storeData"           dc:"门店数据"`
}

// StoreMemberExportModel 导出门店账号管理
type StoreMemberExportModel struct {
	Id                  int64       `json:"id"                  dc:"id"`
	StoreId             int64       `json:"storeId"             dc:"门店 id"`
	MemberId            int64       `json:"memberId"            dc:"账号 id"`
	IsAdmin             int         `json:"isAdmin"             dc:"是否是管理员"`
	CreatedAt           *gtime.Time `json:"createdAt"           dc:"创建时间"`
	AdminMemberRealName string      `json:"adminMemberRealName" dc:"真实姓名"`
	AdminMemberUsername string      `json:"adminMemberUsername" dc:"帐号"`
	AdminMemberAvatar   string      `json:"adminMemberAvatar"   dc:"头像"`
	AdminMemberMobile   string      `json:"adminMemberMobile"   dc:"手机号码"`
}

// StoreMemberSwitchInp 更新门店账号管理开关状态
type StoreMemberSwitchInp struct {
	form.SwitchReq
	Id int64 `json:"id" v:"required#id不能为空" dc:"id"`
}

func (in *StoreMemberSwitchInp) Filter(ctx context.Context) (err error) {
	return
}

type StoreMemberSwitchModel struct{}

type StoreMemberAUInp struct {
	ID       int64  `json:"id"       dc:"id"`
	RealName string `json:"realName" v:"required#真实姓名不能为空" dc:"真实姓名"`
	Phone    string `json:"phone"    v:"required|phone-loose#手机号不能为空|手机号格式不正确" dc:"手机号"`
	Avatar   string `json:"avatar"   dc:"头像"`
	Sex      int    `json:"sex"  dc:"性别"`
	StoreId  int64  `json:"storeId"  dc:"门店 id"`
}

func (in *StoreMemberAUInp) Filter(ctx context.Context) (err error) {
	return nil
}

type StoreMemberAUModel struct {
	Id int64 `json:"id" dc:"id"`
}

type StorePermissionInp struct {
	StoreId int64 `json:"storeId" v:"required#storeId不能为空" dc:"门店ID"`
	IsAdmin int   `json:"isAdmin" dc:"是否是管理员"`
}

type StoreDataInp struct {
	StoreId int64 `json:"storeId" v:"required#storeId不能为空" dc:"门店ID"`
}

type StoreDataModel struct {
	TotalRevenue             float64 `json:"totalRevenue" dc:"总流水"`
	TotalGroupBuyRevenue     float64 `json:"totalGroupBuyRevenue" dc:"团购流水 - 总流水"`
	TodayGroupBuyRevenue     float64 `json:"todayGroupBuyRevenue" dc:"团购流水 - 今日流水"`
	TotalGroupBuyQuantity    int     `json:"totalGroupBuyQuantity" dc:"团购销量 - 总销量"`
	TodayGroupBuyQuantity    int     `json:"todayGroupBuyQuantity" dc:"团购销量 - 今日销量"`
	TotalMemberSalesQuantity int     `json:"totalMemberSalesQuantity" dc:"会员销售 - 总销量"`
	TodayMemberSalesQuantity int     `json:"todayMemberSalesQuantity" dc:"会员销售 - 今日销量"`
	TotalRedemptionCount     int     `json:"totalRedemptionCount"   dc:"权益核销 - 总核销次数"`
	TodayRedemptionCount     int     `json:"todayRedemptionCount"   dc:"权益核销 - 今日核销次数"`
	TotalMemberRevenue       float64 `json:"totalMemberRevenue" dc:"会员流水 - 总金额"`
	TodayMemberRevenue       float64 `json:"todayMemberRevenue" dc:"会员流水 - 今日金额"`
}
